<template>
  <div class="mbti-container">
    <div class="header">
      <h1>MBTI人格类型展示</h1>
      <p class="subtitle">探索16种不同的人格类型及其特点</p>
    </div>
    
    <div class="carousel-wrapper">
      <el-carousel 
        :interval="5000" 
        type="card" 
        height="550px"
        indicator-position="outside"
        arrow="always"
      >
      <el-carousel-item v-for="role in records" :key="role.id">
      <!-- 轮播项内容 -->
      <div class="role-card">
        <div class="role-header">
          <div class="role-mal">{{ role.mal }}</div>
          <h2 class="role-name">{{ role.name }}</h2>
        </div>
        
        <div class="role-content">
          <div class="role-description">
            <h3>人格描述</h3>
            <p>{{ role.description }}</p>
          </div>
          
          <div class="role-details">
            <div class="detail-item">
              <span class="detail-label">领导模式:</span>
              <span>{{ role.ladder }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">解决问题方式:</span>
              <span>{{ role.solve }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">适合领域:</span>
              <span>{{ role.are }}</span>
            </div>
          </div>
        </div>
        
        <div class="role-footer">
          <el-tag type="info" class="role-tag">人格类型</el-tag>
          <el-tag type="success" class="role-tag">{{ role.mal }}</el-tag>
        </div>
      </div>
    </el-carousel-item>
      </el-carousel>
    </div>
    
    <div class="statistics">
      <div class="stat-card">
        <div class="stat-value">16</div>
        <div class="stat-label">人格类型</div>
      </div>
      <div class="stat-card">
        <div class="stat-value">4</div>
        <div class="stat-label">核心维度</div>
      </div>
      <div class="stat-card">
        <div class="stat-value">100+</div>
        <div class="stat-label">职业建议</div>
      </div>
    </div>
    
    <div class="info-section">
      <h2>MBTI人格类型简介</h2>
      <p>迈尔斯-布里格斯类型指标（MBTI）是一种人格类型理论模型，基于卡尔·荣格的心理学类型理论发展而来。它将人的性格分为16种类型，每种类型由4个维度构成：</p>
      <ul>
        <li>精力来源：外向(E) - 内向(I)</li>
        <li>认知方式：实感(S) - 直觉(N)</li>
        <li>判断方式：思考(T) - 情感(F)</li>
        <li>生活方式：判断(J) - 知觉(P)</li>
      </ul>
    </div>
  </div>
</template>

<script lang="ts">
import {getAll} from '@/api/role'

export default {
  data() {
    return {
      records: []
    };
  },
  created(){
    this.getAllRoles()
  },
  methods:{
    getAllRoles(){
 //参数准备
 const params = {}
      //发啥Ajax请求，访问后端服务，获取分页数据
      getAll(params).then(res => {
        if(res.data.code === 1){
          this.records = res.data.data
        }
      }).catch(err =>{
        this.$message.error('请求出错：' + err.message)
      })
    }
  }
};
</script>

<style>
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

body {
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
  min-height: 100vh;
  font-family: 'Noto Sans SC', sans-serif;
  color: #333;
}

.mbti-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 20px;
}

.header {
  text-align: center;
  margin-bottom: 40px;
}

.header h1 {
  font-size: 2.5rem;
  color: #2c3e50;
  margin-bottom: 10px;
  font-weight: 700;
}

.subtitle {
  font-size: 1.2rem;
  color: #7f8c8d;
  max-width: 600px;
  margin: 0 auto;
}

.carousel-wrapper {
  background: white;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  padding: 25px;
  margin-bottom: 40px;
}

.role-card {
  background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 12px;
  padding: 25px;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.role-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.role-header {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.role-mal {
  font-size: 1.8rem;
  font-weight: 800;
  color: #3498db;
  margin-bottom: 5px;
}

.role-name {
  font-size: 1.6rem;
  color: #2c3e50;
  margin: 0;
}

.role-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.role-description {
  margin-bottom: 20px;
}

.role-description h3 {
  color: #3498db;
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.role-description p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #555;
}

.role-details {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 15px;
  margin-top: auto;
}

.detail-item {
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.detail-item:last-child {
  margin-bottom: 0;
}

.detail-label {
  font-weight: 600;
  color: #2c3e50;
  display: inline-block;
  width: 100px;
}

.role-footer {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.role-tag {
  margin: 0 5px;
  font-weight: 500;
}

/* 轮播指示器样式 */
.el-carousel__indicator {
  padding: 12px 5px;
}

.el-carousel__button {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #bdc3c7;
}

.el-carousel__indicator.is-active .el-carousel__button {
  background-color: #3498db;
}

/* 箭头样式 */
.el-carousel__arrow {
  background-color: rgba(255, 255, 255, 0.7);
  color: #3498db;
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.el-carousel__arrow:hover {
  background-color: #3498db;
  color: white;
  transform: scale(1.1);
}

/* 统计卡片样式 */
.statistics {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 40px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 25px 30px;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease;
  min-width: 150px;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: #3498db;
  margin-bottom: 10px;
}

.stat-label {
  font-size: 1.1rem;
  color: #7f8c8d;
}

/* 信息区域样式 */
.info-section {
  background: white;
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.info-section h2 {
  color: #2c3e50;
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 1.8rem;
}

.info-section p {
  line-height: 1.8;
  margin-bottom: 20px;
  color: #555;
}

.info-section ul {
  padding-left: 20px;
}

.info-section li {
  margin-bottom: 10px;
  line-height: 1.6;
  color: #555;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header h1 {
    font-size: 2rem;
  }
  
  .carousel-wrapper {
    padding: 15px;
  }
  
  .role-card {
    padding: 20px;
  }
  
  .statistics {
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }
  
  .stat-card {
    width: 80%;
  }
  
  .el-carousel {
    height: 380px !important;
  }
}

@media (max-width: 480px) {
  .header h1 {
    font-size: 1.8rem;
  }
  
  .subtitle {
    font-size: 1rem;
  }
  
  .role-name {
    font-size: 1.4rem;
  }
  
  .el-carousel {
    height: 450px !important;
  }
  
  .role-content {
    overflow-y: auto;
  }
}
</style>